<?php
namespace Admin\Model;
use Think\Model;

class UserModel extends Model
{
    protected $_validate = array(
        array('user_email', 'require', '用户邮箱不能为空', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
        array('user_email', '', '用户邮箱已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
    );

    protected $_auto = array(
        array('user_pass', 'pass_md5', self::MODEL_BOTH, 'function'),
        array('last_login_time', NOW_TIME, self::MODEL_INSERT),
        array('last_login_ip', 'getUserIp', 1,'callback'),
        array('user_status', 1, self::MODEL_INSERT),
        array('user_jifen', 0, self::MODEL_INSERT),
        array('reg_time', NOW_TIME, self::MODEL_INSERT),
        array('reg_ip', 'getUserIp', 1,'callback'),
        array('wx_openid', '', self::MODEL_BOTH),
        array('qq_openid', '', self::MODEL_BOTH),
    );

    public function getUserIp(){
        return  get_client_ip(0);
    }

}
?>